home *** CD-ROM | disk | FTP | other *** search
/ Loadstar Extras 3 / Ex3side1.d64 / rle in basic (.txt) < prev    next >
Commodore BASIC  |  2022-08-28  |  884b  |  50 lines

  1. 10 input"input file";f$:input"out file";o$
  2. 30 a=49152:b=peek(175)*256+peek(174):c=51200
  3. 40 gosub70:b=x:gosub11030
  4. 50 print"orig:"b-a:print"out:"c-51200:gosub105:end
  5. 70 open2,8,2,f$+",p,r":get#2,a$,a$:x=49152
  6. 80 get#2,a$:pokex,asc(a$+chr$(0)):x=x+1:ifst=0then80
  7. 90 close2:return
  8. 105 open2,8,2,"@0:"+o$+",p,w":print#2,chr$(0)chr$(16);:x=51200
  9. 110 print#2,chr$(peek(x));:x=x+1:ifx<=cthen110
  10. 120 close2:return
  11. 11000 a=peek(252)*256+peek(251)
  12. 11010 b=peek(254)*256+peek(253)
  13. 11020 c=peek(250)*256+peek(249)
  14. 11030 i=a:d=0:e=0
  15. 11040 fori=atob-1
  16. 11050 n=peek(i)
  17. 11060 j=i+1
  18. 11070 q=peek(j)
  19. 11080 ifq=nthengosub11120
  20. 11090 ifq<>nthengosub11220
  21. 11100 next
  22. 11102 ifdthengosub11270
  23. 11104 ifethengosub11340
  24. 11106 pokec,0:return
  25. 11110 end
  26. 11120 ifethengosub11340:rem return
  27. 11130 d=d+1:rem duplicate
  28. 11140 ifd=127thengosub11160
  29. 11150 return
  30. 11160 pokec,d+1
  31. 11170 c=c+1
  32. 11180 pokec,n
  33. 11190 c=c+1
  34. 11200 d=0
  35. 11210 return
  36. 11220 ifdthengosub11270:return
  37. 11230 e=e+1
  38. 11240 ife=1thenf=i
  39. 11250 ife<127thenreturn
  40. 11260 gosub11320:return
  41. 11270 pokec,d+1
  42. 11280 c=c+1
  43. 11290 pokec,n
  44. 11300 c=c+1
  45. 11310 d=0:return
  46. 11320 pokec,eor128:c=c+1
  47. 11330 forj=ftoi:pokec,peek(j):c=c+1:next:e=0:d=0:return
  48. 11340 pokec,eor128:c=c+1
  49. 11350 forj=ftoi-1:pokec,peek(j):c=c+1:next:e=0:d=0:return
  50.